<?php
namespace modules\admin\action\show;

use library\PageAction;
use idea\ap\Ap;
use helper\ErrorNo;
use helper\Util;

/**
 * LoginAction class file
 * 用户登录
 * @author 宋欢 <iphper@yeah.net>
 * @version $Id: LoginAction.php 1 2013-02-08 00:48:06Z huan.song $
 * @package modules.admin.action.show
 * @since 1.0
 */
class LoginAction extends PageAction
{
	/**
	 * @var boolean 是否需要检查用户的登录状态：不检查
	 */
	protected $_checkLogin = false;
	
	/**
	 * (non-PHPdoc)
	 * @see idea\mvc\interfaces.Action::run()
	 */
	public function run()
	{
		$request = Ap::getRequest();

		$ret = array();
		$continue = $request->getTrim('continue');
		$do = $request->getTrim('do');
		if ($do === 'login') {
			$ret = Util::getService('Admins', 'admin')->login($request->getPost());
			if ($ret['err_no'] === ErrorNo::SUCCESS_NUM) {
				Ap::getResponse()->redirect($continue);
			}
		}

		$ret['continue'] = $continue;
		$this->render($ret);
	}
}
